package com.todo.event.activity.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2025/1/7 13:39
 * @description
 */
@Getter
@AllArgsConstructor
public enum EventFieldTypeEnum {

    STRING(1, "STRING", "字符串"),
    LONG(2, "LONG", "整数"),
    DOUBLE(3, "DOUBLE", "小数"),
    ARRAY(4, "ARRAY", "数组"),
    BOOLEAN(5, "BOOLEAN", "布尔"),
    DATE(6, "DATE", "日期"),
    DECIMAL(7, "DECIMAL", "DECIMAL"),
    OBJECT(8, "OBJECT", "对象"),

    UNKNOWN(99, "UNKNOWN", "未知"),
            ;

    private static Map<Integer, EventFieldTypeEnum> typeMap = Arrays
            .stream(EventFieldTypeEnum.values())
            .collect(Collectors.toMap(EventFieldTypeEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static EventFieldTypeEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
